import React from 'react'
import { Tag } from 'antd';
import AxColumnEnum from '../AxColumnEnum/index';
import { AxAnchorText } from '@/components/AxBase';
import { axhelper } from '@/shared/axhelper';
import { axcolor } from './color';

export const AxColumnTagBoolean = (text: any, record: any, index: any) => {
    return (
        AxColumnEnum({ enumName: "axBooleanType", value: text })
    );
};

export const AxColumnTagCustom: React.FC<AxColumnTagCustomProps> = props => {
    const { value, tags = [] } = props
    const tag: any = tags.find((f: any) => f.value === value);

    return (
        <Tag color={tag.color} key={tag.value}>
            {tag.text}
        </Tag>
    );
};

export const AxColumnAnchorText: React.FC<AxColumnTagCustomProps> = props => {
    const { value, tags = [] } = props
    const tag: any = tags.find((f: any) => f.value === value);

    return (
        <AxAnchorText value={tag.text} style={{ color: tag.color, textDecoration: 'underline' }} />
    );
};

export const AxColumnTagEnum: React.FC<AxColumnTagEnumProps> = props => {
    const { enumName, value } = props;

    const text = axhelper.getDicText(enumName, value);
    const color = axcolor(enumName, value);

    return (
        <span style={{ color }}>{text}</span>
    );
    // return (
    //     text && <Tag color={color}>{text}</Tag> || <></>
    // );
};